package com.lieve.bean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.lang.invoke.MethodHandles;

/**
 * @author sunyoboy
 * 2021/5/18
 */
public class Apple implements InitializingBean, DisposableBean {

    private final static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

    private String color;

    public Apple() {
        logger.info("contructor");
    }

    public Apple(String color) {
        logger.info("contructor");
        this.color = color;
        logger.info("after property contructor");
    }

    public String getColor() {
        logger.info("getColor");
        return color;
    }

    public void setColor(String color) {
        logger.info("setColor");
        this.color = color;
    }

    @PostConstruct
    public void postConstruct() {
        logger.info("postConstruct");
    }

    @PreDestroy
    public void preDestroy() {
        logger.info("preDestroy");
    }

    public void initMethod() {
        logger.info("initMethod");
    }

    public void destroyMethod() {
        logger.info("destroyMethod");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("afterPropertiesSet ");
    }

    @Override
    public void destroy() throws Exception {
        logger.info("destroy");
    }
}
